
package com.cy.model;

import com.cy.BasicModel;
import com.cy.ext.plugin.tablebind.TableBind;

import java.util.Date;

/**
* Created with IntelliJ IDEA.
* User: Administrator
* Date: 13-9-9
* Time: 下午12:56
* To change this template use File | Settings | File Templates.
*/
@SuppressWarnings("serial")
@TableBind(tableName="role_label",pkName = "role_id")
public class RoleLabel extends BasicModel<RoleLabel> {
    public static final RoleLabel dao = new RoleLabel();
    public static final String SELECT_ALL = "`role_id`,`role_name`,`level`,`status`,`create_time` ";

    /**
     * 角色
     */
    public enum Role{
        USER(1, "普通用户"),
        INSIDER_TEST(2, "内测用户"),
        TESTER(3, "测试人员"),
        DEVELOPER(4, "研发"),
        ACCENDANT(5, "校维中心"),
        STOREMAN(6, "仓储员"),
        SALESMAN(7, "销售员");

        private Integer id;
        private String desc;

        Role(Integer id, String desc){
            this.id = id;
            this.desc = desc;
        }

        public Integer getId() {
            return id;
        }

        public String getDesc() {
            return desc;
        }
    }

    /**
     * 根据角色名查找角色
     */
    public RoleLabel findByName(String name) {
        return findFirst("select "+ SELECT_ALL +" from role_label where role_name = ?", name);
    }

    public RoleLabel setRoleId (Long roleId){
        this.set("role_id",roleId);
        return this;
    }

    public Long getRoleId (){
        return this. get("role_id");
    }

    public RoleLabel setRoleName (String roleName){
        this.set("role_name",roleName);
        return this;
    }

    public String getRoleName (){
        return this.getStr("role_name");
    }

    public RoleLabel setLevel (Long level){
        this.set("level",level);
        return this;
    }

    public Long getLevel (){
        return this. get("level");
    }

    public RoleLabel setStatus (Long status){
        this.set("status",status);
        return this;
    }

    public Long getStatus (){
        return this. get("status");
    }

    public RoleLabel setCreateTime (Date createTime){
        this.set("create_time",createTime);
        return this;
    }

    public Date getCreateTime (){
        return this.getDate("create_time");
    }

}
